import java.math.BigDecimal;
import java.math.MathContext;

public class Sedan extends Car {

	private Integer length;

	public Sedan(String color, BigDecimal price, Integer length) {
		super(color, price);
		setLength(length);
	}

	public Integer getLength() {
		return length;
	}

	public void setLength(Integer length) {
		this.length = length;
	}

	public BigDecimal getDiscountedPrice() {
		BigDecimal discountedPrice;
		BigDecimal discount;
		MathContext mc = new MathContext(5);

		if (getLength() < 4) {
			discountedPrice = getPrice();
		} else {
			discount = (new BigDecimal(0.05)).multiply(getPrice());
			discountedPrice = getPrice().subtract(discount).round(mc);
		}

		return discountedPrice;
	}
}
